package net.entelijan.cobean.bind.impl;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class NestedABean {

    private static Log log = LogFactory.getLog(NestedABean.class);

    private String strVal;

    private NestedABean beanVal;

    public NestedABean() {
        super();
    }

    public NestedABean(String strVal, NestedABean beanVal) {
        super();
        this.strVal = strVal;
        this.beanVal = beanVal;
    }

    @Override
    public String toString() {
        return "NestedABean (strVal='" + strVal + "' beanVal=" + beanVal + ")";
    }

    @Override
    public final boolean equals(Object obj) {
        boolean re = false;
        if (obj instanceof NestedABean) {
            NestedABean other = (NestedABean) obj;
            EqualsBuilder eb = new EqualsBuilder();
            eb.append(this.getStrVal(), other.getStrVal());
            eb.append(this.getBeanVal(), other.getBeanVal());
            re = eb.isEquals();
            log.debug("[equals] " + re + " instanceof NestedABean '" + this + "'=='" + obj + "'");
        } else {
            log.debug("[equals] " + re + " NOT instanceof NestedABean '" + this + "'=='" + obj + "'");
        }
        return re;
    }

    @Override
    public final int hashCode() {
        return 1;
    }

    public String getStrVal() {
        return strVal;
    }

    public void setStrVal(String strVal) {
        log.debug("[setStrVal] strVal='" + strVal + "' this=" + this);
        this.strVal = strVal;
    }

    public NestedABean getBeanVal() {
        return beanVal;
    }

    public void setBeanVal(NestedABean beanVal) {
        log.debug("[setBeanVal] beanVal='" + beanVal + "' this=" + this);
        this.beanVal = beanVal;
    }

}
